home *** CD-ROM | disk | FTP | other *** search
/ Level 2005 Christmas (DVD) / Level_2005-XMAS_134_DVD_Knightshift.iso / Demos / Ski Racing 2006 / setup1.cab / DataCommonShadersDX9Globe.vsh < prev    next >
Encoding:
Text File  |  2005-11-03  |  1.9 KB  |  85 lines

  1. vs.1.1
  2.  
  3. ;dx9 stuff
  4. ;********
  5. dcl_position v0
  6. ;dcl_blendweight v1
  7. ;dcl_blendindices v2
  8. dcl_normal v3
  9. dcl_binormal v4
  10. dcl_tangent v5
  11. dcl_texcoord0 v7
  12.  
  13. ;Constant map from the NSF.  
  14. ;
  15. ;CM_Defined      WorldViewProjTranspose  0    0
  16. ;CM_Constant     const_1_1_1_255         4    1    1.0,1.0,1.0,765.01
  17. ;CM_Global       DirLight1Direction      5    1   
  18. ;CM_Global       DaCameraPosition        6    1
  19. ;CM_Constant     Half                    7    1   0.5,0.5,0.5,0.5   
  20. ;CM_Defined      InvWorldTranspose       8      0
  21.  
  22. ;Project position
  23. m4x4    oPos, v0, c0
  24.  
  25. ;Transform lightvector from worldspace to object space
  26. mov r5, c5
  27. m3x3 r4, r5, c8
  28.  
  29. ; Normalize light vector.
  30. dp3 r3.x, r4, r4
  31. rsq r2.x, r3.x
  32. mul r0, r4.xyz, r2.xxx
  33.  
  34. ;Transform to tangent space
  35. dp3 r7.x, r0, v5             ;Tangent
  36. dp3 r7.y, r0, v4             ;Binormal
  37. dp3 r7.z, r0, v3             ;Normal
  38. mad oD0.xyz, r7.xyz, c7, c7  ;Scale and bias since texcoord in the pixel shader
  39.                              ;expects a range of 0 to 1.
  40.  
  41.  
  42. ;Specular calculation
  43. ;mov r1, v0
  44.  
  45. ;Transform vertex to world coords
  46. m4x4 r1, v0, c16
  47.  
  48. ;View vector
  49. add r5, -r1, c6
  50.  
  51. ;normalize it
  52. dp3 r3.x, r5.xyz, r5.xyz
  53. rsq r3.xyz, r3.x
  54. mul r5.xyz, r5.xyz, r3.xxx
  55.  
  56. ;Calculate half angle vector
  57. add  r2.xyz, r5.xyz, c5         ;L + V
  58.  
  59. ;Normalize it
  60. dp3  r4.x, r2.xyz, r2.xyz
  61. rsq  r4.xyz, r4.x
  62. mul  r2.xyz, r2.xyz, r4.xyz
  63.  
  64. ;Transform to object space
  65. m3x3 r4, r2, c8
  66.  
  67. ; Normalize half angle vector
  68. dp3 r3.x, r4.xyz, r4.xyz
  69. rsq r3.xyz, r3.x
  70. mul r4.xyz, r4.xyz, r3.xxx
  71.  
  72. ;Transform to tangent space
  73. dp3 r7.x, r4, v5                ;Tangent
  74. dp3 r7.y, r4, v4                ;Binormal
  75. dp3 r7.z, r4, v3                ;Normal
  76. mad oD1.xyz, r7.xyz, c7, c7        ;Scale and bias since texcoord in the pixel shader
  77.  
  78. ;Texture coordinates for the base map and normal map and gloss.
  79. mov oT0.xy, v7.xy
  80. mov oT1.xy, v7.xy
  81. mov oT2.xy, v7.xy
  82.  
  83.  
  84.  
  85.